{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 3 4]\n",
      " [6 9 8]\n",
      " [6 7 9]]\n"
     ]
    }
   ],
   "source": [
    "# Simple things first:\n",
    "import numpy as np\n",
    "\n",
    "mat = np.array([\n",
    "    [1, 3, 4],\n",
    "    [6, 9, 8],\n",
    "    [6, 7, 9]])\n",
    "\n",
    "print(mat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "[U, D, V] = np.linalg.svd(mat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[-0.25545925 -0.60219924  0.75637071]\n",
      " [-0.69818735  0.65607252  0.28653669]\n",
      " [-0.66878622 -0.45489001 -0.58804768]]\n"
     ]
    }
   ],
   "source": [
    "print(U)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[19.19848638  1.66555095  1.28220936]\n"
     ]
    }
   ],
   "source": [
    "print(D)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[-0.44051914  0.36318063 -0.82100105]\n",
      " [-0.61106731  0.54866225  0.57058434]\n",
      " [-0.65767746 -0.75304022  0.01976841]]\n"
     ]
    }
   ],
   "source": [
    "print(np.transpose(V))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Perspective transformation\n",
    "\n",
    "# pick initial and final coords:\n",
    "init_coords = [(0, 0), (1,1), (2, 2), (3,3)] # (xi, yi)\n",
    "final_coords = [(0, 0), (1,1), (2, 2), (3,3)] # (xi',yi') # this should be auto-calculated\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
